/**
 * Created by Administrator on 2016/3/29.
 */
var SPSdk = (function () {
    var PAY_URL = "http://pay.caiguo.com/pay";
    function SPSdk() {
        this.spId = 0;
        this.appId = "";
        this.appKey = "";
        this.token = "";
        this.spFname = "";
        this.openKey = "";
        this.queryParams = {};
    }
    

    var __proto = SPSdk.prototype;


    __proto.login = function (param, callback, shareHandler) {
        var m_this = this;
        console.log("彩果登录：" + JSON.stringify(param));
        callback && callback({"result":0,"spuid":m_this.queryParams.uid,"nickname":decodeURIComponent(m_this.queryParams.uname)});
    }
    __proto.pay = function (param, callback) {
        var m_this = this;
        console.log("彩果支付：" + JSON.stringify(param));
        var data = param.data;
        var callUrl = PAY_URL+"?userId="+m_this.queryParams.uid+"&userName="+m_this.queryParams.uname+"&goodsName="+data.goodsName+"&money="+parseInt(data.amount/100)+"&key="+data.other.key+"&orderId="+data.other.orderId+"&ext="+data.other.orderId+"&gameUrl="+encodeURIComponent(window.location.href);
        window.location.href = callUrl;
    }
    __proto.init = function (param, callback) {
        console.log("彩果初始化：" + JSON.stringify(param));
        var m_this = this;
        m_this.access_token = param.access_token;
        m_this.spId = param.spId;
        m_this.appId = param.appId;
        m_this.spFname = param.spFname;
        m_this.openKey = param.openKey;
        m_this.queryParams = param.queryParams;
        callback && callback({"result": 0, "desc": "OK"});
    }
    return SPSdk;
})();